package com.hsogoo.avatar;

import com.hsogoo.avatar.enums.Protocol;
import com.hsogoo.avatar.model.AvatarRequest;
import com.hsogoo.avatar.model.AvatarResponse;
import com.hsogoo.avatar.processor.DefaultAvatarProcessor;
import com.hsogoo.avatar.model.AvatarAddress;
import com.hsogoo.avatar.transport.AvatarConnection;
import com.hsogoo.avatar.transport.AvatarConnector;
import com.hsogoo.avatar.transport.netty.AvatarNettyConnector;

/**
 * @Author huangsaigang
 * Created @2018/9/30.
 */
public class ClientTest {

    public static void main(String[] args) {
        AvatarConnector connector = new AvatarNettyConnector(Protocol.AVATAR).withProcessor(new DefaultAvatarProcessor());
        AvatarConnection connection = connector.connect(new AvatarAddress("localhost", 8888));
        AvatarRequest request = new AvatarRequest();
        request.setRequestId("123456");
        request.setInterfaceName("className222");
        request.setMethodName("methodName222");
        request.setProtocol(Protocol.AVATAR);
        request.setSerializerCode((byte) 0X02);
        AvatarResponse response = connection.channel().sendRequest(request);
        System.out.println(response.getRequestId());
        System.out.println(response.getResult());
    }
}
